package com.taru.wxhsh.util;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class JwtUtills {


    public static  String createToken(Map<String,Object> header,String claim,String secret ){
        Date iatDate = new Date();
        Calendar nowTime = Calendar.getInstance();
        nowTime.add(Calendar.MINUTE,100);
        Date expiresDate = nowTime.getTime();

        String token = null;
        try {
            token = JWT.create().withHeader(header)
                    .withClaim("info",claim)
                    .withExpiresAt(expiresDate)
                    .withIssuedAt(iatDate)
                    .sign(Algorithm.HMAC256(secret));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return token;

    }


    public static  String  parseToken(){
        return  null;
    }



}
